<?php

namespace app\admin\controller;

use app\admin\model\AdminUser;
use think\Db;
use think\Request;
use think\Response;

class Admin
{
    public function index()
    {
        $admin = (new AdminUser())->getSelect();
        return view('index',['admin'=>$admin]);
    }
    public function del()
    {
     
        $id = Request::instance()->get('id');
        $res = (new AdminUser())->getDel($id);
        if ($res)
        {
          echo 1;die;
        }
        return  redirect('index');
    }
    public function update()
    {
         $id = Request::instance()->get('id');
         $admin = (new AdminUser())->getUpdateFind($id);

         return view('update',['admin'=>$admin,'id'=>$id]);
    }
    public function up()
    {
        $id = Request::instance()->get('id');
        $data= Request::instance()->post();
         $admin = (new AdminUser())->getUp($id,$data);
        if ($admin)
        {
            return  redirect('index');
        }
    }
    public function create()
    {
        if (Request::instance()->isPost())
        {
            $data = Request::instance()->post();

            $res = (new AdminUser())->getCreate($data);


            if ($res)
            {
                return  redirect('index');
            }
        }
        return view('create');
    }
    public function show(){
        return view();
    }
}